<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>用户注册页面</title>
  <style></style>
</head>

<body>
  <!-- 用户注册的内容需要和数据库存储的数据一一对应 -->
  <h1>用户注册页面</h1>
  <hr>
  <label>用户名：</label>
  <input type="text" placeholder="用户名字" id="uname"> <br>
  <label>手机号码：</label>
  <input type="text" placeholder="手机号码" id="uphone">
  <br>
  <label>是否会员：</label>
  <input type="text" placeholder="0为非会员1为会员" id="umember">
  <br>
  <button id="btn">注册</button>
  <hr>
  <h4>可修改本人信息</h4>
  <div id="mydiv">
    <h6 style="color: red;">已注册用户才能点击进入修改界面</h6>
    <a href="./edit.html">修改个人信息</a>
  </div>

  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
  <script>
    $(function () {

      $('#btn').click(function () {
        $.ajax({
          url: '/user/reg',
          data: {
            u_names: $('#uname').val(),
            u_phone: $('#uphone').val(),
            u_member: $('#umember').val(),
          },
          type: 'POST',
          dataType: 'json',
          success: (data) => {
            alert(data.msg)
          },
          error: () => {
            console.log('出错啦!!');
          },
        });
      });
    })
  </script>
</body>

</html>